<?php
// Start session so we can detect logged-in users and redirect them to timer.html
session_start();

$cfg = __DIR__ . DIRECTORY_SEPARATOR . 'config.json';
if (!file_exists($cfg)) {
    // no config => go to init
    header('Location: init.php');
    exit;
}

// If user is already logged in (session exists), send them to timer by default
if (isset($_SESSION['user'])) {
    header('Location: timer.html');
    exit;
}

// otherwise show the auth page
header('Location: auth.html');
exit;

?>
